package com.weibo.user.severlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.weibo.common.BaseSeverlet;
import com.weibo.user.User;
import com.weibo.user.service.UserService;
import com.weibo.user.service.imp.UserServiceImp;

public class CheckUserServerlet extends BaseSeverlet {

	private static final Logger logger = Logger
			.getLogger(CheckUserServerlet.class);

	@Override
	public void doService(HttpServletRequest request,
			HttpServletResponse response) {
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = null;
		try {
			out = response.getWriter();
			// 得到前台的参数值
			String niname = request.getParameter("niname") == null ? "" : request
					.getParameter("niname");
			UserService userservice = new UserServiceImp();
			User user = userservice.getUserByName(niname);
			response.setCharacterEncoding("UTF-8");
			if (user == null) {
				out.print(true);
			} else {
				out.print(false);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}

}
